//
//  RoomMenuPresentationController.m
//  YSSmartHome
//
//  Created by yanghao on 2016/10/9.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "RoomMenuPresentationController.h"


@interface RoomMenuPresentationController ()
@property (nonatomic, strong)UIView *coverView;

@end
@implementation RoomMenuPresentationController
- (instancetype)initWithPresentedViewController:(UIViewController *)presentedViewController presentingViewController:(UIViewController *)presentingViewController
{
    if (self = [super initWithPresentedViewController:presentedViewController presentingViewController:presentingViewController]) {
        
    }
    return self;
}

- (void)setPresentFrame:(CGRect)presentFrame
{
    _presentFrame = presentFrame;
}
- (void)containerViewWillLayoutSubviews
{
 
    self.presentedView.frame = self.presentFrame;
    [self.containerView insertSubview:self.coverView atIndex:0];
}

- (void)close {
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - lazy loading
- (UIView *)coverView
{
    if (!_coverView) {
        _coverView = [[UIView alloc]init];
        
        _coverView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.2];
        _coverView.frame = [UIScreen mainScreen].bounds;
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(close)];
        [_coverView addGestureRecognizer:tapGesture];
    }
    return _coverView;
}
@end
